<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>商品清单页面</title>
    <script>
        function del() {
            return confirm("是否要删除这件商品？删除后无法撤销此操作！！！！")
        }
    </script>
</head>
<body>
<h1>商品列表</h1>
<p><a href="/admin/add.jsp">添加商品</a></p>
<table border="1">
    <tr>
        <th>ID</th>
        <th>商品名</th>
        <th>商品价格</th>
        <th colspan="2">操作</th>
    </tr>
    <c:forEach var="commodity" items="${sessionScope.commodities}">
        <tr>
            <td>${commodity.id}</td>
            <td>${commodity.name}</td>
            <td>${commodity.price}</td>
            <td><a href="/commodity/queryById/${commodity.id}">商品更新</a></td>
            <td><a href="/commodity/removeById/${commodity.id}" onclick="return del()">删除商品</a></td>
        </tr>
    </c:forEach>
</table>
</body>
</html>
